package com.ctgu.算法.快速幂;

import java.util.Scanner;

/**
 * @author: Backdiy
 * @data: 2021/4/17 21:15
 * @desc:
 */
public class 十进制快速幂 {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        System.out.println(pow10(n, m));
    }

    static int pow10(int n, int m) {
        String s = String.valueOf(m);
        int ans = 1;
        int res;
        for (int i = s.length() - 1; i >= 0; i--) {
            int k = s.charAt(i) - '0';
            res = pow2(n, k);
            ans = res * ans;
            n = pow2(n, 10);
        }
        return ans;
    }

    static int pow2(int n, int m) {
        int ans = 1;
        while (m > 0) {
            if ((m & 1) == 1) ans = ans * n;
            m >>= 1;
            n = n * n;
        }
        return ans;
    }
}
